package com.lanbu.chat.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.lanbu.common.annotation.Log;
import com.lanbu.common.core.controller.BaseController;
import com.lanbu.common.core.domain.AjaxResult;
import com.lanbu.common.enums.BusinessType;
import com.lanbu.chat.domain.ImProblemLog;
import com.lanbu.chat.service.IImProblemLogService;
import com.lanbu.common.utils.poi.ExcelUtil;
import com.lanbu.common.core.page.TableDataInfo;

/**
 * 问题反馈Controller
 *
 * @author lanbu
 * @date 2024-09-15
 */
@Api(tags = "问题反馈Controller")
@RestController
@RequestMapping("/chat/feedback")
public class ImProblemLogController extends BaseController
{
    @Autowired
    private IImProblemLogService imProblemLogService;


    @ApiOperation("查询问题反馈列表")
    @PreAuthorize("@ss.hasPermi('chat:feedback:list')")
    @GetMapping("/list")
    public TableDataInfo list(ImProblemLog imProblemLog)
    {
        startPage();
        List<ImProblemLog> list = imProblemLogService.selectImProblemLogList(imProblemLog);
        return getDataTable(list);
    }


    @ApiOperation("导出问题反馈列表")
    @PreAuthorize("@ss.hasPermi('chat:feedback:export')")
    @Log(title = "问题反馈", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ImProblemLog imProblemLog)
    {
        List<ImProblemLog> list = imProblemLogService.selectImProblemLogList(imProblemLog);
        ExcelUtil<ImProblemLog> util = new ExcelUtil<ImProblemLog>(ImProblemLog.class);
        util.exportExcel(response, list, "问题反馈数据");
    }


    @ApiOperation("获取问题反馈详细信息")
    @PreAuthorize("@ss.hasPermi('chat:feedback:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        imProblemLogService.checkProblemLogDataScope(id);
        return success(imProblemLogService.selectImProblemLogById(id));
    }


    @ApiOperation("新增问题反馈")
    @PreAuthorize("@ss.hasPermi('chat:feedback:add')")
    @Log(title = "问题反馈", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ImProblemLog imProblemLog)
    {
        return toAjax(imProblemLogService.insertImProblemLog(imProblemLog));
    }

    @ApiOperation("修改问题反馈")
    @PreAuthorize("@ss.hasPermi('chat:feedback:edit')")
    @Log(title = "问题反馈", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ImProblemLog imProblemLog)
    {
        imProblemLogService.checkProblemLogDataScope(imProblemLog.getId());
        return toAjax(imProblemLogService.updateImProblemLog(imProblemLog));
    }


    @ApiOperation("删除问题反馈")
    @PreAuthorize("@ss.hasPermi('chat:feedback:remove')")
    @Log(title = "问题反馈", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(imProblemLogService.deleteImProblemLogByIds(ids));
    }
}
